package com.dfbz.dao;

import com.dfbz.model.User;
import com.dfbz.utils.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;


public class UserDao {

    public User findByName(String username){
        String sql = "select * from user where username = ?";
        QueryRunner qr = new QueryRunner(JDBCUtil.getDataSource());
        User user = null;
        try {
             user = qr.query(sql, new BeanHandler<>(User.class),username);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return user;
    }


}
